<?php
// View for admin - articles
require_once WACT_ROOT.'controller/controller.inc.php';
require_once WACT_ROOT .'controller/form.inc.php';
require_once WACT_ROOT.'view/view.inc.php';
require_once WACT_ROOT .'view/formview.inc.php';

require_once APP_ROOT . 'view/common/layout.formview.php';
require_once APP_ROOT . 'view/common/layout.view.php';

require_once 'model/common/user.php';
require_once 'model/common/statdivisions.php';
require_once 'model/common/categories.php';
require_once 'model/common/date.php';


class DivisionsListView extends LayoutFormView {

    function DivisionsListView($TemplateFile) {
    	//parent :: $IsAdminView = true;
        parent :: LayoutFormView($TemplateFile);
    }



    function prepare(&$controller, &$request, &$responseModel) {
    	parent::prepare($controller, $request, $responseModel);
        $pager =& $this->Template->getChild('pagenav');
        $pager2 =& $this->Template->getChild('pagenav2');
        $list =& Division::getDivisionsList($pager,$request,$responseModel);
        $list->paginate($pager2);


        $list_updated=array();


        $list->reset();
        while ($list->next()) {

        	$dataspace = $list->export();

            $divisionID = $list->get('divisionID');

            $enable = $list->get('enabled');
            if ($enable) $dataspace['status_show'] =  'enabled';
            else $dataspace['status_show'] =  'disabled';
            if ($enable) $dataspace['enabled_show'] =  1;

            //print_r($dataspace);
            $list_updated[$divisionID] = $dataspace;
        }


        $list_source_updated =& new ArrayDataSet($list_updated);
        $this->Template->setChildDataSource('List', $list_source_updated);

        //populate sort combo
        $sortby =& $this->Template->getChild('sort');
        $sort_list = array('divisionName'=>'Name','divisionID'=>'ID','date_added desc'=>'Date');
        $sortby->setChoices($sort_list);


    }

}






?>